<html xmlns:th="http://www.thymeleaf.org" class="x-admin-sm">
<head>
    <script src="/js/jquery-3.4.1.js"></script>
    <script src="/lib/layui/layui.js"></script>
    <script src="/js/xadmin.js"></script>
    <link href="/lib/layui/css/layui.css" rel="stylesheet">
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css"
          integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

    <!-- 可选的 Bootstrap 主题文件（一般不用引入） -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap-theme.min.css"
          integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"
            integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
            crossorigin="anonymous"></script>
    <script charset="utf-8" src="/kindeditor/kindeditor-all.js"></script>
    <script charset="utf-8" src="/kindeditor/lang/zh-CN.js"></script>
    <script>
        KindEditor.ready(function (K) {
            window.editor = K.create('#content',
                {
                    cssPath: 'kindeditor/plugins/code/prettify.css',
                    uploadJson: '/uploads',
                    allowFileManager: false
                });

        });
    </script>
</head>
<body>
<div class="row" style="width: 90%; margin-left: 5%">
    <form method="post" class="layui-form" action="/self/commodity/save">
        <input type="hidden" id="id">
        <h3>商品上架</h3>
        <div class="form-group">
            <label>商品名</label>
            <input type="text" class="form-control" id="" name="name"/>
        </div>
        <div class="form-group">
            <label>价格</label>
            <input type="text" class="form-control" name="price"/>
        </div>
        <div class="form-group">
            <label>库存</label>
            <input type="text" class="form-control" name="stock"/>
        </div>
        <div class="form-group">
            <label>预览图</label>
            <img src="/images/kodinger.jpg" id="setImg" width="50" height="50">
            <input type="hidden" class="lowin-btn" name="img" id="img" value="/img/kodinger.jpg">
        </div>
        <div class="form-group">
            <label>商品介绍</label>
            <textarea name="description" id="content"></textarea>
        </div>
        <input type="submit" value="提交" class="btn btn-default">
    </form>
</div>
<script>
    function doSubmit() {

    }

    layui.use('upload', function () {
        var upload = layui.upload;

        //执行实例
        var uploadInst = upload.render({
            elem: '#setImg' //绑定元素
            , url: '/upload/' //上传接口
            , done: function (res) {
                //上传完毕回调
                if (res.error == 0) {
                    $("#setImg").attr("src", res.url)
                    $("#img").val(res.url)
                } else {
                    alert(res.message)
                }
            }
            , error: function () {
                //请求异常回调
            }
        });
    });

    layui.use('laydate', function () {
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });
        laydate.render({
            elem: '#end' //指定元素
        });
    });
</script>
</body>
</html>
